/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client;

import java.rmi.Naming;


import server._ZoneExchange;

import server.$ZoneExchange;
import server.ZoneExchange;

/**
 *
 * @author Qiao BingZhi
 */
public class Client {

    private String hostName = "127.0.0.1";
    private String serverName = "Server";
    private boolean connect = false;
    private _ZoneExchange info=null;
    private String port="1099";

    /**
     * Get the value of port
     *
     * @return the value of port
     */
    public String getPort() {
        return port;
    }

    /**
     * Set the value of port
     *
     * @param port new value of port
     */
    public void setPort(String port) {
        this.port = port;
    }


    /**
     * Client's constructor
     */
    public Client() {
        try
        {
            info=new ZoneExchange();

        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    /**
     * Get the value of connectStatu
     *
     * @return the value of connectStatu
     */
    public boolean isConnect() {
        return connect;
    }

    /**
     * Set the value of connectStatu
     *
     * @param connectStatu new value of connectStatu
     */
    public void setConnect(boolean connect) {
        this.connect = connect;
    }

    /**
     * Get the value of serverName
     *
     * @return the value of serverName
     */
    public String getServerName() {
        return serverName;
    }

    /**
     * Set the value of serverName
     *
     * @param serverName new value of serverName
     */
    public void setServerName(String serverName) {
        this.serverName = serverName;
    }

    /**
     * Get the value of hostName
     *
     * @return the value of hostName
     */
    public String getHostName() {
        return hostName;
    }

    /**
     * Set the value of hostName
     *
     * @param hostName new value of hostName
     */
    public void setHostName(String hostName) {
        this.hostName = hostName;
    }


    public _ZoneExchange run() {
        try {

            this.info = (_ZoneExchange) Naming.lookup("rmi://" + this.hostName + "/" + this.serverName);
            this.connect = true;
        } catch (Exception e) {
            e.getStackTrace();
            this.connect = false;
        }
        return this.info;
    }
}
